/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplerecipes;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author matamh0a
 */
public class ResourcesLoader {
    private String defaultResourcePath;
    
    private static ResourcesLoader instance;
    
    public static ResourcesLoader getInstance() {
        if(instance == null)
            instance = new ResourcesLoader();
        return instance;
    }

    public ResourcesLoader() {
        try {
            Properties prop = new Properties();
            System.out.println(System.getProperty("user.home") + File.separator +  ".utopia");
            prop.load(new FileInputStream(
                    System.getProperty("user.home")  + File.separator + ".utopia"));
            System.out.println(System.getProperty("user.home") + "/.utopia");
            defaultResourcePath = prop.getProperty("default");
        } catch (IOException ex) {
            Logger.getLogger(ResourcesLoader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public String getDefaultResourcePath() {
        return defaultResourcePath;
    }
    
    public String getResourcePathForWeb(String path) {
        return ("file:///" + defaultResourcePath + path).replace("\\", "/");
    }
    
}
